package org.malred.hotelsystem.fragment.admin;

import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.tabs.TabLayout;

import org.malred.hotelsystem.R;
import org.malred.hotelsystem.adapter.OrderPagerAdapter;
import org.malred.hotelsystem.fragment.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 显示订单列表, 点击可以退订|入住...
 */
public class ManageOrderFragment extends BaseFragment {
    private static final String TAG = "ManageOrderFragment";
    TabLayout mTabLayout;
    ViewPager2 mViewPager2;
    private List<String> mData = new ArrayList<>();

    @Override
    protected int setLayoutResourceID() {
        return R.layout.fragment_manage_order;
    }

    @Override
    protected void setUpView() {
        mTabLayout = getContentView().findViewById(R.id.home_indicator);
        mViewPager2 = getContentView().findViewById(R.id.home_pager);
        OrderPagerAdapter homePagerAdapter = new OrderPagerAdapter(getActivity(), mData);
        mViewPager2.setAdapter(homePagerAdapter);

        // todo - bug: 不显示tab
//        new TabLayoutMediator(mTabLayout, mViewPager2, new TabLayoutMediator.TabConfigurationStrategy() {
//            @Override
//            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
//                // 传入下标
//                tab.setText(mData.get(position));
//            }
//        }).attach();
    }

    @Override
    protected void setUpData() {
        // 给每个页面的数据
        mData.add("页面1");
        mData.add("页面2");
        mData.add("页面3");
    }
}